package org.serverct.finalfight.game.listener.player;

import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.serverct.finalfight.game.GameManager;
import org.serverct.finalfight.internal.game.basic.BasicGame;

public class DamageListener implements Listener {
    @EventHandler
    public void onDamaged(EntityDamageEvent event) {
        Entity entity = event.getEntity();
        if (entity instanceof Player) {
            BasicGame game = GameManager.getGame((Player) entity);
            if (game == null) {
                return;
            }
            if (game.timeCounter <= 60) {
                event.setCancelled(true);
            }
        }
    }
}
